package cn.ickck.law_paper_final.controller;


import cn.ickck.law_paper_final.model.entity.Gdb;
import cn.ickck.law_paper_final.model.entity.GdbBatch;
import cn.ickck.law_paper_final.model.entity.Pa;
import cn.ickck.law_paper_final.model.entity.PaBatch;
import cn.ickck.law_paper_final.model.response.PaBatchResponse;
import cn.ickck.law_paper_final.service.PaBatchService;
import cn.ickck.law_paper_final.service.PaService;
import cn.ickck.law_paper_final.utils.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.*;

/**
 * @Author: ck
 * @Description:
 * @Date: Create in 13:04 2020/12/13
 */

@RestController
@RequestMapping("/api/v2/pub/pa_batch")
public class PaBatchController {
    @Autowired
    private PaBatchService paBatchService;

    @Autowired
    private PaService paService;

    @RequestMapping("selectByPage")
    public JsonData selectByPage(Integer page) {
        PaBatchResponse paBatchResponse = new PaBatchResponse();
        int count = paBatchService.count();
        int start = PageHelperUtils.getStart(count, page);
        int end = PageHelperUtils.getEnd(count, page);
        List<PaBatch> paBatchList = paBatchService.selectByPage(start, end);
        paBatchResponse.setCount(count);
        paBatchResponse.setPaBatchList(paBatchList);
        return JsonData.buildSuccess(paBatchResponse);
    }

    @Transactional
    @RequestMapping("delete")
    public JsonData deleteById(Integer id) {

        //还应该把这一批次的所有信息都删除
        //根据id查询到key
        String key = paBatchService.selectKeyById(id);
        //根据key删除相应信息

        //需要引入事务 以后再说
        //
        paService.deleteByKey(key);
        paBatchService.deleteById(id);

        return JsonData.buildSuccess();
    }

    @RequestMapping("update")
    public JsonData update(@RequestBody PaBatch paBatch) {
        paBatchService.update(paBatch);
        return JsonData.buildSuccess("更新成功");
    }

    @RequestMapping("selectByName")
    public JsonData selectByName(@Param("name") String name, @Param("page") int page)
    {
        System.out.println(name+page);
        PaBatchResponse paBatchResponse = new PaBatchResponse();
        List<PaBatch> paBatchList = paBatchService.selectByName(name);
        int start = PageHelperUtils.getStart(paBatchList.size(),page);
        int end  = PageHelperUtils.getEnd(paBatchList.size(),page);
        List<PaBatch> paBatchList1 = new ArrayList<>();
        for(int i  = start;i<end;i++)
        {
            paBatchList1.add(paBatchList.get(i));
        }
        paBatchResponse.setCount(paBatchList.size());
        paBatchResponse.setPaBatchList(paBatchList1);
        return JsonData.buildSuccess(paBatchResponse);

    }
    @RequestMapping("exportExcel")
    public void exportExcel(@RequestBody PaBatch paBatch, HttpServletResponse httpServletResponse)throws Exception
    {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());
        ExcelUtils.exportExcel(paList, Pa.class, paBatch.getName() + ".xlsx", httpServletResponse);

    }

    @RequestMapping("exportWord")
    public void exportWord(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"到庭判决-解除.ftl","到庭判决-解除",response);

    }
    @RequestMapping("exportWord1")
    public void exportWord1(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"到庭判决书.ftl","到庭判决书",response);

    }
    @RequestMapping("exportWord2")
    public void exportWord2(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"到庭判决未-到期.ftl","到庭判决未-到期",response);

    }
    @RequestMapping("exportWord3")
    public void exportWord3(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"民事起诉状-额度模板.ftl","民事起诉状-额度模板",response);

    }
    @RequestMapping("exportWord4")
    public void exportWord4(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"民事起诉状-数额.ftl","民事起诉状-数额",response);

    }
    @RequestMapping("exportWord5")
    public void exportWord5(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"缺席判决-到期.ftl","缺席判决-到期",response);

    }
    @RequestMapping("exportWord6")
    public void exportWord6(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"缺席判决-未到期.ftl","缺席判决-未到期",response);

    }
    @RequestMapping("exportWord7")
    public void exportWord7(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"查封裁定-模板.ftl","查封裁定-模板",response);

    }
    @RequestMapping("exportWord8")
    public void exportWord8(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"基础裁定-模板.ftl","基础裁定-模板",response);

    }
    @RequestMapping("exportWord14")
    public void exportWord9(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"终本询问笔录-模板.ftl","终本询问笔录-模板",response);

    }
    @RequestMapping("exportWord9")
    public void exportWord10(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"强制执行申请书-模板.ftl","强制执行申请书-模板",response);

    }
    @RequestMapping("exportWord10")
    public void exportWord11(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"执行裁定书-模板.ftl","执行裁定书-模板",response);

    }
    @RequestMapping("exportWord11")
    public void exportWord12(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"执行卷宗封面封底-模板.ftl","执行卷宗封面封底-模板",response);

    }
    @RequestMapping("exportWord12")
    public void exportWord13(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"执行通知书-模板.ftl","执行通知书-模板",response);

    }
    @RequestMapping("exportWord13")
    public void exportWord14(HttpServletResponse response, @RequestBody PaBatch paBatch)throws Exception
    {
        List<Pa> PaList = paService.selectByNameOrKey(paBatch.getKey());
        Map data = new HashMap<>();
        System.out.println("调用方法");

        data.put("PaList", PaList);
        WordUtil.exportWord(data,"终本裁定之三-模板.ftl","终本裁定之三-模板",response);

    }


    @RequestMapping("exportZip")
    public void exportZip(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "到庭判决-解除.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }


    @RequestMapping("exportZip1")
    public void exportZip1(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "到庭判决书.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip2")
    public void exportZip2(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "到庭判决未-到期.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip3")
    public void exportZip3(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "民事起诉状-额度模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip4")
    public void exportZip4(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "民事起诉状-数额.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip5")
    public void exportZip5(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "缺席判决-到期.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip6")
    public void exportZip6(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "缺席判决-未到期.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip7")
    public void exportZip7(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "查封裁定-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip8")
    public void exportZip8(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "基础裁定-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip9")
    public void exportZip9(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "强制执行申请书-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip10")
    public void exportZip10(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "执行裁定书-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip11")
    public void exportZip11(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "执行卷宗封面封底-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip12")
    public void exportZip12(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "执行通知书-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip13")
    public void exportZip13(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "终本裁定之三-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }
    @RequestMapping("exportZip14")
    public void exportZip14(HttpServletResponse httpServletResponse, @RequestBody PaBatch paBatch) {

        List<Pa> paList = paService.selectByNameOrKey(paBatch.getKey());

        List<File> files = new ArrayList<>();
        for (Pa pa : paList) {

            Map data = new HashMap<>();
            List<Pa> paList1 = new ArrayList<>();
            paList1.add(pa);
            data.put("PaList",paList1);

            String filePath = FileUtils.getWordPath();
            //文件唯一名称
            String fileOnlyName = pa.getName() + UUID.randomUUID().toString() + ".doc";
            /** 生成word  数据包装，模板名，文件生成路径，生成的文件名*/

            WordUtil.createWord(data, "终本询问笔录-模板.ftl", filePath, fileOnlyName);
            File f = new File(filePath + File.separator + fileOnlyName);
            files.add(f);
        }

        //调用压缩
        String time = System.currentTimeMillis() + "";
        String zipFilePath = FileUtils.getWordPath() + File.separator + time + ".zip";
        try {
            ZipUtil.create(zipFilePath, files);
            //下载文件
            File f = new File(zipFilePath);
            if (f.exists()) {
                ZipUtil.downloadZip(f, httpServletResponse);
//                DownLoadFileUtil.setResponseHeader(response,zipFilePath);
            } else {
                System.out.println("文件不存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (File file : files) {
            file.delete();
        }

    }











}
